--
-- Created by IntelliJ IDEA.
-- User: ping.wang
-- Date: 2018/7/9
-- Time: 下午2:34
-- To change this template use File | Settings | File Templates.
--

local fileName = string.getModeName(...)
local ClassRef = class(fileName)

function ClassRef:ctor(data)
    assert(data)
    self._allNormalClassify = {}
    self._allBidClassify = {}

    for k,v in ipairs(data) do
        if tonumber(v.ID) < 2000 then
            local firMenuKey = tonumber(v.menuId)
            if not self._allNormalClassify[firMenuKey] then
                self._allNormalClassify[firMenuKey] = {name =  L(v.firMenu), id = firMenuKey}
                self._allNormalClassify[firMenuKey].subDatas ={}
            end
            local subDatas = self._allNormalClassify[firMenuKey].subDatas or {}
            table.insert(subDatas, {name = L(v.name), id = tonumber(v.ID) } )
            self._allNormalClassify[firMenuKey].subDatas = subDatas
        else
            local firMenuKey = tonumber(v.menuId)
            if not self._allBidClassify[firMenuKey] then
                self._allBidClassify[firMenuKey] = {name =  L(v.firMenu), id = firMenuKey}
                self._allBidClassify[firMenuKey].subDatas ={}
            end
            local subDatas = self._allBidClassify[firMenuKey].subDatas or {}
            table.insert(subDatas, {name = L(v.name), id = tonumber(v.ID) } )
            self._allBidClassify[firMenuKey].subDatas = subDatas
        end
    end

    --dump(self._allNormalClassify," ---------->>>>> :_parseTargetsList",10)
    --dump(self._allBidClassify," ---------->>>>> :_parseTargetsList",10)
end

function ClassRef:getData(type)
    --此处是一个1级分类 下二级分类集合
    if type == nil then return end

    if type == Enums.AuctionProductType.normal then
        return self._allNormalClassify
    elseif type == Enums.AuctionProductType.bid then
        return self._allBidClassify
    end
end

return ClassRef